//
//  WBVisitorTableViewController.swift
//  微博(swift)
//
//  Created by 汤米 on 16/4/18.
//  Copyright © 2016年 汤米. All rights reserved.
//

import UIKit

class WBVisitorTableViewController: UITableViewController {

    //是否登录标识
    var isLogin: Bool = WBUserAccountTool.sharedAccountTool.isLogin
    
    var visitorView: WBVisitorView?
    override func loadView() {
        
        isLogin ? super.loadView() : setUpVisitorView()
        
    }
    
    // MARK: -  设置访客视图
    private func setUpVisitorView() {
        
        setNav()
        visitorView = WBVisitorView()
        visitorView?.visitorClosure = {
            
            self.login()
        }
        view = visitorView
    }
    
    // MARK: -  设置导航栏
    private func setNav() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
    }
    
    
    // MARK: -  注册.登录按钮的点击事件
    func login() {
        
        let autorizeVc = WBAuthorizeViewController()
        presentViewController(UINavigationController(rootViewController: autorizeVc), animated: true, completion: nil)
    }
    
}
